<!DOCTYPE HTML>
<html ng-app="reres">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/popup.css"/>
    <script type="text/javascript" src="js/angular.min.js"></script>
    <script type="text/javascript" src="js/popup.js"></script>
</head>
<body ng-controller="mapListCtrl">
<div class="container">
<div class="btnBox">
    <button tabIndex="-1" class="btn btn-primary btn-xs" ng-click="addRule()">添加规则</button>
    <a href="options.html" target="_blank" tabIndex="-1" class="btn btn-primary btn-xs">管理规则</a>
    <a href="https://github.com/hanan198501/ReRes" target="_blank" tabIndex="-1" class="btn btn-primary btn-xs">Github</a>
    <a href="http://cssha.com/reres" target="_blank" tabIndex="-1" class="btn btn-primary btn-xs">使用帮助</a>
</div>

<div style="display:{{editDisplay}};" class="editBox">
    <button type="button" class="close" aria-hidden="true" ng-click="hideEditBox()">&times;</button>
    <div class="errorMsg">{{inputError}}</div>
    <div class="form-group">
        <label for="req">If URL match:</label>
        <input type="text" class="form-control" id="req" ng-model="curRule.req"/>
    </div>
    <div class="form-group">
        <label for="res">Response:</label>
        <input type="text" class="form-control" id="res" ng-model="curRule.res"/>
    </div>
    <div class="form-group">
        <label for="res">Group:</label>
        <input type="text" class="form-control" id="group" ng-model="curRule.group"/>
    </div>
    <!--<div class="form-group">
        <label for="type">Type:</label>
        <select ng-model="curRule.type" class="form-control" id="type">
            <option value="file">URL映射</option>
            <option value="dir">目录映射</option>
        </select>
    </div>-->
    <button class="btn-block btn btn-primary" ng-click="saveRule()">保存</button>
</div>
<div ng-repeat="(group, rulesMap) in rules track by $index">
    <h5 style="text-align: center;font-weight: bold;">[{{group || group === unidefined || '未命名'}}]</h5>
    <table class="table table-hover">
        <tr ng-repeat="rule in rulesMap track by $index">
            <td>
                <label title="Responese: {{rule.res}}"><input type="checkbox" ng-model="rule.checked"/> {{rule.req}}</label>
                <button ng-click="edit(rule)" type="button" class="btn btn-primary btn-xs edit">编辑</button>
                <button ng-click="removeUrl(rule)" type="button" class="btn btn-default btn-xs remove">删除</button>
            </td>
        </tr>
    </table>
</div>

</div>
</body>
</html>